package com.myproject.thread.pool;

import java.util.concurrent.*;

public class Test1 {

    private static Executor executor = Executors.newFixedThreadPool(10);
    //private static Executor executor = Executors.newCachedThreadPool();
    public static void main(String[] args) throws InterruptedException {

        for (int i = 0; i < 5; i++) {
            executor.execute(new Task());
        }

        for (int i = 0; i < 10; i++) {
            Thread.sleep(3000);
            System.out.println(((ThreadPoolExecutor)executor).getActiveCount());
            if (i==9){
                break;
            }
        }

    }

    static class Task implements Runnable{

        @Override
        public void run() {
            System.out.println(Thread.currentThread().getName());
        }
    }

}
